home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC05Cust.Wind / CWnd.Inits.asm < prev    next >
Encoding:
Assembly Source File  |  1990-04-18  |  9.7 KB  |  277 lines  |  [04] ASCII Text (0x0000)

  1.  
  2.                     EJECT
  3. *******************************************************************************
  4. *
  5. InitTools           start
  6. *
  7. * Description:      Load and initialize the tools needed. Errors are detected
  8. *                   and FatalError is called if any occur. If there aren't any
  9. *                   errors, the list of menu templates is read and the menu-
  10. *                   bar is created.
  11. *
  12. *
  13. * Inputs:           NONE
  14. *
  15. * Outputs:          NONE
  16. *
  17. * External Refs:
  18. *                   Import FatalError
  19. *
  20. * Entry Points:     NONE
  21. *
  22. *******************************************************************************
  23.                     using Globals
  24.  
  25. ;
  26. ;   Tool Direct page offsets here
  27. ;
  28. QDDPage             equ $0000
  29. EMDPage             equ QDDPage+$0300
  30. CtlDPage            equ EMDPage+$0100
  31. MenuDPage           equ CtlDPage+$0100
  32. LEDPage             equ MenuDPage+$0100
  33. ToolDPSize          equ LEDPage+$0100
  34.  
  35.                     phk                 ; Save program bank register and
  36.                     plb                 ; load it as the data bank register
  37.  
  38.                     tdc
  39.                     sta MyDP            ; Save direct register
  40.  
  41.                     _TLStartup          ; Start Tool Locator
  42.  
  43.                     pha                 ; Space for result
  44.                     _MMStartup          ; Start memory manager
  45.                     PullWord MyID       ; Save it for later use
  46.  
  47.                     _MTStartup          ; Start up Misc Tools
  48.  
  49.                     _IMStartup          ; Start integer math toolset
  50.  
  51.                     PushLong #ToolTable ; Pointer to Tool table
  52.                     _LoadTools          ; Load all RAM based tools
  53.                     bcc IT0005          ; Carry clear means no error
  54.                     brl FatalError      ; Tools can't be loaded. Fatal error!
  55.  
  56. IT0005              ANOP
  57.  
  58. ; Get memory for Tool Direct pages
  59.  
  60.                     pha                 ; Room for result
  61.                     pha
  62.                     PushLong #ToolDPSize ; Number of bytes needed
  63.                     PushWord MyID       ; ID of this application
  64.                     PushWord #attrLocked+attrFixed+attrPage+attrBank
  65.                     PushLong #0         ; Allocate them in bank 0
  66.                     _NewHandle
  67.                     bcc IT0010          ; Test carry for error
  68.                     brl FatalError      ; If no memory we got a fatal error!
  69.  
  70. IT0010              PullLong DPHandle   ; Retrieve handle to our DPage area
  71.  
  72.                     lda [<DPHandle]     ; Dereference the handle to get a ptr
  73.                     sta DPPointer       ; to our direct page area and save it.
  74.  
  75.                     PushWord DPPointer  ; QuickDraw uses 3 pages of Dpage
  76.                     PushWord #ScreenMode ; Used to set all master SCB's
  77.                     PushWord #0         ; Zero means use default buf size
  78.                     PushWord MyID       ; Application ID for allocating data
  79.                     _QDStartup          ; Start QuickDraw, turn on SHR Screen
  80.                     bcc IT0015
  81.                     brl FatalError      ; If it can't be started then bomb
  82.  
  83. IT0015              ANOP
  84.                     lda DPPointer       ; Create address for Event Mgr DPage by
  85.                     clc                 ; loading in the pointer to the start
  86.                     adc #EMDPage        ; of DPage and adding Evt Mgr offset.
  87.                     pha                 ; Now push it on the stack.
  88.                     PushWord #20        ; Size of event queue.
  89.                     PushWord #0         ; MouseClamp values.
  90.                     PushWord #ScreenWidth ; These will clamp mouse to screen
  91.                     PushWord #0         ; area only.
  92.                     PushWord #200
  93.                     PushWord MyID
  94.                     _EMStartup          ; Start the event manager
  95.                     bcc IT0020
  96.                     brl FatalError      ; Event manager is also a must
  97. IT0020              ANOP
  98.                     PushWord MyID
  99.                     _WindStartup
  100.                     bcc IT0025
  101.                     brl FatalError
  102. IT0025              ANOP
  103.                     PushWord MyID
  104.                     lda DPPointer
  105.                     clc
  106.                     adc #CtlDPage
  107.                     pha
  108.                     _CtlStartup
  109.                     bcc IT0030
  110.                     brl FatalError
  111. IT0030              ANOP
  112.  
  113.                     PushWord MyID
  114.                     lda DPPointer
  115.                     clc
  116.                     adc #MenuDPage
  117.                     pha
  118.                     _MenuStartUp
  119.                     bcc IT0035
  120.                     brl FatalError
  121. IT0035              ANOP
  122.                     PushWord MyID
  123.                     lda DPPointer
  124.                     clc
  125.                     adc #LEDPage
  126.                     pha
  127.                     _LEStartUp
  128.                     bcc IT0040
  129.                     brl FatalError
  130. IT0040              ANOP
  131.                     PushWord MyID
  132.                     _DialogStartup
  133.                     bcc IT0045
  134.                     brl FatalError
  135. IT0045              ANOP
  136.                     _ScrapStartup       ; No errors possible for this call
  137.  
  138.                     _DeskStartup        ; No error possible for this call
  139.  
  140. ; insert application specific tools here
  141.  
  142.                     PushLong #0
  143.                     _RefreshDeskTop
  144.  
  145. ;
  146. ; Create the menus I need
  147. ;
  148.  
  149.                     ldx #MenuPtrLen-4   ; Get a pointer to the last menu
  150. loop                phx                 ; Save menu table index on the stack
  151.                     pha                 ; Push on space for the menu handle
  152.                     pha                 ;   returned by NewMenu
  153.                     lda MenuPtr+2,x     ; Push on the pointer to the template
  154.                     pha                 ;   to be used by NewMenu when
  155.                     lda MenuPtr,x       ;   creating the menu
  156.                     pha
  157.                     _NewMenu            ; Create a new menu
  158.                     PushWord #0         ; Tell InsertMenu where to put it
  159.                     _InsertMenu         ; Insert it.
  160.                     plx                 ; Get our index back off the stack
  161.                     dex                 ; Point to the next template pointer
  162.                     dex
  163.                     dex
  164.                     dex
  165.                     bpl loop            ; Go back up if not done yet.
  166.  
  167.                     PushWord #1         ; Add NDA's
  168.                     _FixAppleMenu
  169.  
  170.                     pha                 ; Now call CalcMenuSize for all menus
  171.                     _FixMenuBar
  172.                     PullWord MenuHeight
  173.  
  174.                     _DrawMenuBar        ; Finally, draw it.
  175.  
  176.                     RTS
  177.  
  178. ToolTable           dc i2'6'            ; Data Block for LoadTools call
  179.                     dc i2'14,$0100'     ; Window Manager
  180.                     dc i2'15,$0100'     ; Menu Manager
  181.                     dc i2'16,$0100'     ; Control Manager
  182.                     dc i2'20,$0100'     ; LineEdit tool set
  183.                     dc i2'21,$0100'     ; Dialog Manager
  184.                     dc i2'22,$0100'     ; Scrap manager
  185.  
  186.                     end
  187.  
  188.                     EJECT
  189. *******************************************************************************
  190. *
  191. FatalError          start
  192. *
  193. * Description:      Routine that is called whenever a tool sends back an error
  194. *                   that can not be recovered from. This routine prints the
  195. *                   error on the screen, waits for a keypress then quits back
  196. *                   to whoever started this application up!
  197. *
  198. *
  199. * Inputs:           A = Error number
  200. *
  201. * Outputs:          NONE (program exits)
  202. *
  203. * External Refs:
  204. *                   Import CloseTools
  205. *
  206. * Entry Points:     NONE
  207. *
  208. *******************************************************************************
  209.                     using Globals
  210.  
  211.                     pha                 ; Push the error code
  212.                     PushLong #ErrNumStr ; Address of storage area
  213.                     PushWord #4         ; Length of string
  214.                     _Int2Hex
  215.  
  216.                     _GrafOff            ; If QD Started, shut off graphics
  217.  
  218.                     PushLong #ErrStr    ; Write error message to the screen
  219.                     _WriteCString
  220.  
  221.                     pha                 ; Space for result
  222.                     PushWord #0         ; No echo
  223.                     _ReadChar           ; Wait for a key to be pressed
  224.                     pla                 ; Discard the key
  225.  
  226.                     jsr CloseTools      ; Shut down all the tools in case
  227. ;                                         any got started up
  228.  
  229.                     _Quit QuitParms     ; Quit back to where we came from.
  230.  
  231.                     brk $FF             ; If the quit fails then just break
  232.  
  233. ErrStr              dc c'A fatal error has occured $'
  234. ErrNumStr           dc c'xxxx   press any key to exit',i1'0'
  235.  
  236.                     end
  237.  
  238.                     EJECT
  239. *******************************************************************************
  240. *
  241. CloseTools          start
  242. *
  243. * Description:      Shut down the tools I started.
  244. *
  245. *
  246. * Inputs:           NONE
  247. *
  248. * Outputs:          NONE
  249. *
  250. * External Refs:    NONE
  251. *
  252. * Entry Points:     NONE
  253. *
  254. *******************************************************************************
  255.                     using Globals
  256.  
  257.                     _DeskShutDown
  258.                     _ScrapShutDown
  259.                     _DialogShutDown
  260.                     _LEShutDown
  261.                     _MenuShutDown
  262.                     _CtlShutDown
  263.                     _WindShutDown
  264.                     _EMShutDown
  265.                     _QDShutDown
  266.                     _MTShutDown
  267.  
  268.                     PushLong DPHandle   ; Dispose of all that DP memory
  269.                     _DisposeHandle
  270.  
  271.                     PushWord MyID
  272.                     _MMShutDown
  273.                     _TLShutDown
  274.  
  275.                     rts
  276.                     end
  277.